package com.xbj.springmvc.core.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.xbj.springmvc.core.util.LoadSpringMVCConfigUtil;

public class XBJListener implements ServletContextListener{

	private ServletContext context;

	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println(getClass()+" listener init started");
		context= event.getServletContext();
		String path = context.getRealPath("")+context.getInitParameter("springmvc");
		Map<String, String> map = LoadSpringMVCConfigUtil.LoadSpringMVCConfig(path);
		context.setAttribute("springmvc", map);
		Map<String, String> map2 = (Map<String, String>) context.getAttribute("springmvc");
		for(String key:map2.keySet()){
			System.err.println("key:"+key+"<===>value:"+map2.get(key)); 
		}
		System.out.println(getClass()+" listener init finished");
	}
	
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		System.out.println(getClass()+" listener destroy finished");
	}

}
